package com.bclz.task.flowpartitioner;

import java.util.HashMap;
import java.util.Map;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;

public class FlowPartitioner extends Partitioner<Text, FlowObject> {
		
	
	private static Map<String,Integer> provinceCode=new HashMap<>();
	
	static {
		
		provinceCode.put("137", 1);
		provinceCode.put("138", 2);
		provinceCode.put("159", 3);
		provinceCode.put("134", 4);
		provinceCode.put("135", 5);
	}
	
	
	@Override
	public int getPartition(Text phone, FlowObject val, int partitionNum) {
		// TODO Auto-generated method stub
		Integer code = provinceCode.get(phone.toString().substring(0, 3));
		return code==null?0:code;
	}

}
